package com.jic.product.impl;

import java.lang.Long;
import java.util.List;

import com.jic.product.entity.ProductPropertyValue;
import com.jic.product.mapper.ProductPropertyValueMapper;
import com.jic.product.manage.request.ProductPropertyValueEditRequest;
import com.jic.product.manage.request.ProductPropertyValueRequest;
import com.jic.product.service.ProductPropertyValueService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品属性名称值表
 * @author : 
 * @email : 
 * @since : 2020-01-10 07:03:01
 * @version : v1.0.0
 */
@Service
public class ProductPropertyValueServiceImpl implements ProductPropertyValueService{

    @Autowired
    private ProductPropertyValueMapper productPropertyValueMapper;

    @Override
    public long insert(ProductPropertyValueEditRequest productPropertyValue) {
        long flag = productPropertyValueMapper.insert(productPropertyValue);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return productPropertyValueMapper.delete(id);
    }

    @Override
    public long update(ProductPropertyValue productPropertyValue) {
        return productPropertyValueMapper.update(productPropertyValue);
    }

    @Override
    public ProductPropertyValue queryByPrimaryKey(Long id){
        return productPropertyValueMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<ProductPropertyValue> query(ProductPropertyValueRequest productPropertyValueRequest){
        return productPropertyValueMapper.query(productPropertyValueRequest);
    }

    @Override
    public PageResult<ProductPropertyValue> queryPage(ProductPropertyValue productPropertyValue, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<ProductPropertyValue> list = productPropertyValueMapper.queryPage(startIndex, pageQuery.getLimit(), productPropertyValue);
        long count = productPropertyValueMapper.queryPageCount(productPropertyValue);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}